import 'package:meiyunapp/entity/goods_detail_entity.dart';
import 'package:meiyunapp/entity/near_bystore_entity.dart';

goodsDetailEntityFromJson(GoodsDetailEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['storeId'] != null) {
		data.storeId = json['storeId'] is String
				? int.tryParse(json['storeId'])
				: json['storeId'].toInt();
	}
	if (json['images'] != null) {
		data.images = (json['images'] as List).map((v) => v.toString()).toList().cast<String>();
	}
	if (json['descImages'] != null) {
		data.descImages = (json['descImages'] as List).map((v) => v.toString()).toList().cast<String>();
	}
	if (json['costPrice'] != null) {
		data.costPrice = json['costPrice'] is String
				? int.tryParse(json['costPrice'])
				: json['costPrice'].toInt();
	}
	if (json['salesPrice'] != null) {
		data.salesPrice = json['salesPrice'] is String
				? int.tryParse(json['salesPrice'])
				: json['salesPrice'].toInt();
	}
	if (json['activePrice'] != null) {
		data.activePrice = json['activePrice'] is String
				? int.tryParse(json['activePrice'])
				: json['activePrice'].toInt();
	}
	if (json['couponId'] != null) {
		data.couponId = json['couponId'];
	}
	if (json['voucherId'] != null) {
		data.voucherId = json['voucherId'];
	}
	if (json['price'] != null) {
		data.price = json['price'];
	}
	if (json['stock'] != null) {
		data.stock = json['stock'] is String
				? int.tryParse(json['stock'])
				: json['stock'].toInt();
	}
	if (json['availableDay'] != null) {
		data.availableDay = json['availableDay'] is String
				? int.tryParse(json['availableDay'])
				: json['availableDay'].toInt();
	}
	if (json['availableDays'] != null) {
		data.availableDays = json['availableDays'].toString();
	}
	if (json['duration'] != null) {
		data.duration = json['duration'] is String
				? int.tryParse(json['duration'])
				: json['duration'].toInt();
	}
	if (json['numberOfPeople'] != null) {
		data.numberOfPeople = json['numberOfPeople'] is String
				? int.tryParse(json['numberOfPeople'])
				: json['numberOfPeople'].toInt();
	}
	if (json['reservation'] != null) {
		data.reservation = json['reservation'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['gender'] != null) {
		data.gender = json['gender'] is String
				? int.tryParse(json['gender'])
				: json['gender'].toInt();
	}
	if (json['genderText'] != null) {
		data.genderText = json['genderText'].toString();
	}
	if (json['sensitiveFlag'] != null) {
		data.sensitiveFlag = json['sensitiveFlag'] is String
				? int.tryParse(json['sensitiveFlag'])
				: json['sensitiveFlag'].toInt();
	}
	if (json['notice'] != null) {
		data.notice = json['notice'].toString();
	}
	if (json['remark'] != null) {
		data.remark = json['remark'];
	}
	if (json['categoryIds'] != null) {
		data.categoryIds = json['categoryIds'].toString();
	}
	if (json['store'] != null) {
		data.store = GoodsDetailStore().fromJson(json['store']);
	}
	if (json['buyFlag'] != null) {
		data.buyFlag = json['buyFlag'] is String
				? int.tryParse(json['buyFlag'])
				: json['buyFlag'].toInt();
	}
	if (json['refundDesc'] != null) {
		data.refundDesc = json['refundDesc'].toString();
	}
	return data;
}

Map<String, dynamic> goodsDetailEntityToJson(GoodsDetailEntity entity) {
	final Map<String, dynamic> data = Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['storeId'] = entity.storeId;
	data['images'] = entity.images;
	data['descImages'] = entity.descImages;
	data['costPrice'] = entity.costPrice;
	data['salesPrice'] = entity.salesPrice;
	data['activePrice'] = entity.activePrice;
	data['couponId'] = entity.couponId;
	data['voucherId'] = entity.voucherId;
	data['price'] = entity.price;
	data['stock'] = entity.stock;
	data['availableDay'] = entity.availableDay;
	data['availableDays'] = entity.availableDays;
	data['duration'] = entity.duration;
	data['numberOfPeople'] = entity.numberOfPeople;
	data['reservation'] = entity.reservation;
	data['status'] = entity.status;
	data['gender'] = entity.gender;
	data['genderText'] = entity.genderText;
	data['sensitiveFlag'] = entity.sensitiveFlag;
	data['notice'] = entity.notice;
	data['remark'] = entity.remark;
	data['categoryIds'] = entity.categoryIds;
	data['store'] = entity.store.toJson();
	data['buyFlag'] = entity.buyFlag;
	data['refundDesc'] = entity.refundDesc;
	return data;
}

goodsDetailStoreFromJson(GoodsDetailStore data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['address'] != null) {
		data.address = json['address'].toString();
	}
	if (json['longitude'] != null) {
		data.longitude = json['longitude'] is String
				? double.tryParse(json['longitude'])
				: json['longitude'].toDouble();
	}
	if (json['latitude'] != null) {
		data.latitude = json['latitude'] is String
				? double.tryParse(json['latitude'])
				: json['latitude'].toDouble();
	}
	if (json['contactMobile'] != null) {
		data.contactMobile = json['contactMobile'].toString();
	}
	if (json['contactMobile2'] != null) {
		data.contactMobile2 = json['contactMobile2'];
	}
	if (json['businessStartTime'] != null) {
		data.businessStartTime = json['businessStartTime'].toString();
	}
	if (json['businessEndTime'] != null) {
		data.businessEndTime = json['businessEndTime'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['images'] != null) {
		data.images = json['images'];
	}
	if (json['coverImage'] != null) {
		data.coverImage = json['coverImage'].toString();
	}
	if (json['products'] != null) {
		data.products = (json['products'] as List).map((v) => NearBystoreListProducts().fromJson(v)).toList();
	}
	if (json['cityId'] != null) {
		data.cityId = json['cityId'] is String
				? int.tryParse(json['cityId'])
				: json['cityId'].toInt();
	}
	if (json['tagIds'] != null) {
		data.tagIds = json['tagIds'];
	}
	if (json['customerService'] != null) {
		data.customerService = json['customerService'].toString();
	}
	return data;
}

Map<String, dynamic> goodsDetailStoreToJson(GoodsDetailStore entity) {
	final Map<String, dynamic> data = Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['address'] = entity.address;
	data['longitude'] = entity.longitude;
	data['latitude'] = entity.latitude;
	data['contactMobile'] = entity.contactMobile;
	data['contactMobile2'] = entity.contactMobile2;
	data['businessStartTime'] = entity.businessStartTime;
	data['businessEndTime'] = entity.businessEndTime;
	data['status'] = entity.status;
	data['images'] = entity.images;
	data['coverImage'] = entity.coverImage;
	data['products'] =  entity.products.map((v) => v.toJson()).toList();
	data['cityId'] = entity.cityId;
	data['tagIds'] = entity.tagIds;
	data['customerService'] = entity.customerService;
	return data;
}

goodsDetailStoreProductsFromJson(NearBystoreListProducts data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['coverImage'] != null) {
		data.coverImage = json['coverImage'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['costPrice'] != null) {
		data.costPrice = json['costPrice'] is String
				? int.tryParse(json['costPrice'])
				: json['costPrice'].toInt();
	}
	if (json['salesPrice'] != null) {
		data.salesPrice = json['salesPrice'] is String
				? int.tryParse(json['salesPrice'])
				: json['salesPrice'].toInt();
	}
	if (json['activePrice'] != null) {
		data.activePrice = json['activePrice'] is String
				? int.tryParse(json['activePrice'])
				: json['activePrice'].toInt();
	}
	if (json['stock'] != null) {
		data.stock = json['stock'] is String
				? int.tryParse(json['stock'])
				: json['stock'].toInt();
	}
	if (json['totalSales'] != null) {
		data.totalSales = json['totalSales'] is String
				? int.tryParse(json['totalSales'])
				: json['totalSales'].toInt();
	}
	if (json['couponId'] != null) {
		data.couponId = json['couponId'];
	}
	if (json['voucherId'] != null) {
		data.voucherId = json['voucherId'];
	}
	if (json['price'] != null) {
		data.price = json['price'];
	}
	if (json['categoryIds'] != null) {
		data.categoryIds = json['categoryIds'].toString();
	}
	if (json['storeId'] != null) {
		data.storeId = json['storeId'];
	}
	if (json['buyFlag'] != null) {
		data.buyFlag = json['buyFlag'] is String
				? int.tryParse(json['buyFlag'])
				: json['buyFlag'].toInt();
	}
	return data;
}

Map<String, dynamic> goodsDetailStoreProductsToJson(NearBystoreListProducts entity) {
	final Map<String, dynamic> data = Map<String, dynamic>();
	data['id'] = entity.id;
	data['coverImage'] = entity.coverImage;
	data['name'] = entity.name;
	data['costPrice'] = entity.costPrice;
	data['salesPrice'] = entity.salesPrice;
	data['activePrice'] = entity.activePrice;
	data['stock'] = entity.stock;
	data['totalSales'] = entity.totalSales;
	data['couponId'] = entity.couponId;
	data['voucherId'] = entity.voucherId;
	data['price'] = entity.price;
	data['categoryIds'] = entity.categoryIds;
	data['storeId'] = entity.storeId;
	data['buyFlag'] = entity.buyFlag;
	return data;
}